#include <time.h>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include "test_album.h"

namespace ct {
struct A {
  std::vector<int> x;
};
struct B {
  std::vector<int> x;
};
struct C : public A {
};

struct D {
  D(std::string &str) : str(str) { }
  std::string& str;
};

int test() {
  std::string h("hello"), w("world");
  D a(h), b(w);
  std::cout << a.str << ", " << b.str << "\n";
  //a = b; //won't compile, refer to effective c++ 05
  return 0;
}

static int const n = 100000000;

void fill(A &a) {
  for (int i = 0; i < n; ++i) {
    a.x.push_back(333);
  }
}

void test1() {
  clock_t t0 = clock();
  C c;
  fill(c);
  clock_t t1 = clock();
  printf("test1:%d\n", t1 - t0);
}

void test2() {
  clock_t t0 = clock();
  A a;
  B b;
  fill(a);
  b.x = a.x;
  clock_t t1 = clock();
  printf("test2:%d\n", t1 - t0);
}

void SimpleTest::Run(int argc, char *argv[]) {
  test1();
  test2();
  test();
}
} // ct
